package com.black.quick.dao;

import com.black.quick.domain.QuickGoods;
import com.black.quick.vo.GoodsVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

import java.util.List;

@Mapper
@Component
public interface GoodsDao {
	
	@Select("select g.*,qg.stock_count, qg.start_date, qg.end_date,qg.quick_price from quick_goods qg left join goods g on qg.goods_id = g.id")
	public List<GoodsVo> listGoodsVo();

	@Select("select g.*,qg.stock_count, qg.start_date, qg.end_date,qg.quick_price from quick_goods qg left join goods g on qg.goods_id = g.id where g.id = #{goodsId}")
	public GoodsVo getGoodsVoByGoodsId(@Param("goodsId") long goodsId);

	@Update("update quick_goods set stock_count = stock_count - 1 where goods_id = #{goodsId}")
	public int reduceStock(QuickGoods g);
	
}
